<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
/**
 * @var Mage_Page_Block_Html_Header $this
 */
?>

<?php
	/*配置项*/
	$topListMenu   = $this->getChildHtml('topListMenu') ;/*全站分类导航*/
	$keywordsobj   = $this->getChildHtml('seo.searchterm');/*热门搜索关键词*/
	$bannerdisplay = $this->getLayout()->createBlock('cms/block')->setBlockId('Total-station-top-banner')->toHtml();/*top 广告 Banner*/
	$customerId =Mage::getModel('customer/session')->getId();

	//配置7月活动时间段
	date_default_timezone_set('Etc/GMT-3');//获取时区
	$nowtime = time();//获取当前时间
	$starttimestr   = strtotime("2016-07-04 09:00:00");//活动开始时间
	$endtimestr     = strtotime("2016-07-17 24:00:00");//活动结束时间
		
	//配置Url
	$routeName = $this->helper('core/url')->getCurrentUrl();//当前页面路径
	$homeUrl   = $this->getUrl('');//首页路径
	
	$route_ru  = $homeUrl."?___store=default&___from_store=russia";//首页英文路径
	$route_cn  = $homeUrl."?___store=russia&___from_store=default"; //首页俄文路径 
	
	/* lie 只在首页显示 */
	$moduleName 	= $this->getRequest()->getModuleName();
	$controllerName = $this->getRequest()->getControllerName();
	$actionName 	= $this->getRequest()->getActionName();
	if($moduleName == 'cms' && $controllerName == 'index' && $actionName == 'index'){
		echo $sharedisplay = $this->getLayout()->createBlock('cms/block')
							 ->setBlockId('em0131-marketdeal-one-key-share')->toHtml();/*one key share*/
	}
	/* lie 只在首页显示 */
?>

<!-- you	全站页面添加banner横幅 2016-04-14 -->
<?php if ($bannerdisplay): ?>
	<div id="bannerAsd" class="owl-carousel">
		<?php echo $bannerdisplay ?>
	</div>
	<?php $bannerdisplays =  substr_count($bannerdisplay , "<p>") ; ?>
	<?php if ($bannerdisplays > 1): ?>
		<script type="text/javascript">
			//<![CDATA[
			(function($){
				$('#bannerAsd').owlCarousel({
					singleItem: true,
					autoPlay: true,
					pagination:true,
					scrollPerPage: false,
					stopOnHover: true,
					lazyLoad: true,
					navigation:true,
					transitionStyle : 'fade',	
				})
			})(jQuery);
			//]]>
		</script>
	<?php else : ?>
		<script type="text/javascript">
		//<![CDATA[
		(function($){
			$('#bannerAsd').owlCarousel({
				singleItem: true,
				scrollPerPage: false,
			});
		})(jQuery);
		//]]>
	</script>
	<?php endif ?>
<?php endif ?>
<!-- you	全站页面添加banner横幅 2016-04-14 -->



<?php if(Mage::helper('themeframework/settings')->checkTabletPhp()!=1):?>
<div id="em-mheader" class="visible-xs container">
    <div id="em-mheader-top" class="row">
		<div id="em-mheader-logo" class="col-sm-4"><!-- <?php //echo $this->getLogoSrcSmall() ?> -->
            <div class="em-logo"><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><strong><?php echo $this->getLogoAlt() ?></strong>

<!-- you logo更换 2016-3-21 -->
            <img src="<?php echo Mage::getUrl();?>skin/frontend/em0131/em0131_marketdeal/images/logo2.png" alt="<?php echo $this->getLogoAlt() ?>" />
<!-- you logo更换 2016-3-21 -->

            </a></div>
        </div>
		<div class="col-sm-20">		
			<div class="em-top-search"><?php echo $this->getChildHtml('topsearch_mobile') ;?></div>			
			<div class="em-top-cart"><?php echo $this->getChildHtml('em_topcart_mobile'); ?></div>			
			<div id="em-mheader-wrapper-menu">
				<span class="visible-xs fa fa-bars" id="em-mheader-menu-icon"></span>
				<div id="em-mheader-menu-content" style="display: none;">
					<div class="em-wrapper-top">
						<div class="em-language-currency row">
							<div class="col-sm-24">
								<?php echo $this->getChildHtml('store_language_mobile') ?>
								<?php echo $this->getChildHtml('currency_style_mobile') ?>
							</div>
						</div>
						<div class="em-top-links row">
							<div class="">
								<ul class="top-header-link links">
									<?php if (Mage::getSingleton('customer/session')->isLoggedIn()!=0): ?> 
										<li class="first col-sm-8">
											<a title="<?php echo $this->__('My Account')?>" class="account-link fa fa-user" href="<?php echo $this->getBaseUrl()?>customer/account/" ><span><?php echo $this->__('My Account') ?></span></a>
										</li>
										<li class="col-sm-8">
											<a title="<?php echo $this->__('Log out')?>" class='account-link fa fa-sign-out' href=" <?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK).'customer/account/logout' ?>"><span><?php echo $this->__('Log out')?></span></a>
										</li>
									<?php else:?>
										<li class="first col-sm-8">
											<a title="<?php echo $this->__('Log In')?>" class="login-link fa fa-user" href="<?php echo $this->getBaseUrl()?>customer/account/login/" ><span><?php echo $this->__('Log In') ?></span></a>
										</li>
										<li class="col-sm-8">
											<a title="<?php echo $this->__('Sign up')?>" class='signup-link fa fa-sign-out' href=" <?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK).'customer/account/create' ?>"><span><?php echo $this->__('Sign up')?></span></a>
										</li>
									<?php endif;?>		
									<li class="last col-sm-8">
										<a href="<?php echo $this->getBaseUrl()?>checkout/cart" class="checkout-link fa fa-shopping-cart"><span><?php echo $this->__('Cart') ?></span></a>
									</li>
								</ul>
							</div>
						</div>
					</div>
					<div class="row mobile-main-menu toggle-menu">
						<div class="col-sm-24">
							<div class="em-top-menu">
								<?php echo $this->getChildHtml('topMenuMobile') ?>
							</div>
						</div>
					</div>
					<div class="row mobile-block">
						<div class="col-sm-24"><?php echo $this->getChildHtml('em_area_header_mobile') ?></div>
					</div>
				</div>
			</div>
		</div>   
    </div>
</div> 
<script type="text/javascript">
//<![CDATA[
    (function($) {
        function fixNavigationMobileView(){
            var $_winW = $(window).width();
            var $_mmenu = $('#em-mheader-menu-content');
            var elem = $('#em-mheader-menu-content');      
            var $_parent = $('#em-mheader-wrapper-menu');     
            var $_iconNav = $('#em-mheader-menu-icon');     
            if(!isPhone || $_winW>767){ 
                $_mmenu.removeClass(); 
                $_iconNav.removeClass('active');
                elem.removeClass('show');
                $_parent.removeClass('active'); 
            }        
        };
        function fixNavOverFlow(){
            var $_iconNav = $('#em-mheader-menu-icon');
            var elem = $('#em-mheader-menu-content');      
            var $_parent = $('#em-mheader-wrapper-menu');
            $_iconNav.click(function(e){
                e.preventDefault();        
                var self = $(this);                
                var isSkipContentOpen = elem.hasClass('show') ? 1 : 0;   
                self.removeClass('active');
                elem.removeClass('show');                 
                $_parent.removeClass('active');    
                if (isSkipContentOpen) {
                    self.removeClass('active');  
                    $_parent.removeClass('active');              
                } else {
                    self.addClass('active');
                    elem.addClass('show'); 
                    $_parent.addClass('active');                
                }                 
            }); 
            if(isPhone){
                $_parent.on("swipeleft",function(){
                    var self = $(this);
                    if(self.hasClass('active')){
                        elem.removeClass('show'); 
                        $_iconNav.removeClass('active');
                        self.removeClass('active'); 
                    }                
                }); 
            }                       
        };
        $(document).ready(function(){            
            if (EM.SETTING.DISABLE_RESPONSIVE != 0) {
                fixNavigationMobileView(); 
                fixNavOverFlow(); 
            }            
        });
        $(window).resize($.throttle(300,function(){
            if (EM.SETTING.DISABLE_RESPONSIVE != 0) {
                fixNavigationMobileView();   
            }
        })); 
    })(jQuery);
//]]>
</script>
<?php endif;?>
<?php if(Mage::helper('themeframework/settings')->checkPhone()!=1):?> 
<div class="hidden-xs em-header-style31">
    <div class="em-header-top">
        <div class="container">
            <div class="row">
                <div class="col-sm-24">
					<div class="em-wrapper-header-top">
						<div class="em-language-currency f-left">
							<?php echo $this->getChildHtml('store_language_style01') ?>
							<?php echo $this->getChildHtml('em_currency_style01') ?>                    
						</div>						 
						<div class="em-top-links">
							<div class="f-right"><?php echo $this->getChildHtml('topLinks') ?></div>
							<div class="f-right"><?php echo $this->getChildHtml('topLinksWishlist') ?></div>
							<ul class="list-inline f-right">
								<?php if (Mage::getSingleton('customer/session')->isLoggedIn()==0): ?>
									<li><a class="em-register-link" href="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK).'customer/account/create/'; ?>" title="<?php echo $this->__('Register') ?>"><?php echo $this->__('Register') ?></a></li>
								<?php else: ?>
									<li><a href="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK).'customer/account/'; ?>" class="em-account-link" title="<?php echo $this->__('My Account') ?>"><?php echo $this->__('My Account') ?></a></li>
									<li><a href="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK).'customer/account/logout'; ?>" class="em-logout-link" title="<?php echo $this->__('Log Out') ?>"><?php echo $this->__('Log Out') ?></a></li>  
								<?php endif;?>
							</ul>
							<div id="em-login-link" class="account-link f-right <?php if (Mage::getSingleton('customer/session')->isLoggedIn()==0): ?>em-non-login<?php else:?>em-logged<?php endif;?>">
								<?php if (Mage::getSingleton('customer/session')->isLoggedIn()==0): ?>
									<a href="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK).'customer/account/login/'; ?>" class="link-account" id="link-login" title="<?php echo $this->__('Login') ?>"><?php echo $this->__('Login') ?></a>   
									<?php if(Mage::helper('themeframework/settings')->getGeneral_DisableHoverLogin()!=0 && !Mage::helper('themeframework/settings')->checkPhone()): ?>         
										<?php $login = new Mage_Customer_Block_Form_Login(); ?>                
							
<!-- you 隐藏login弹出框 2016-3-16	 -->	
<!--					
										<div class="em-account" id="em-account-login-form" style="display: none;">                
											<form action="<?php //echo $login->getPostActionUrl() ?>" method="post" id="top-login-form">
												<?php //echo $this->getBlockHtml('formkey'); ?>
												<div class="block-content">
													<p class="login-title h6 primary"><?php //echo $this->__('Login') ?></p>
													<p class="login-desc"><?php //echo $this->__('If you have an account with us, please log in.') ?></p>
													<ul class="form-list">
    													<li><label for="mini-login"><?php //echo $this->__('Email Address') ?><em><?php //echo $this->__('*') ?></em></label>
    														<input type="text" name="login[username]" id="mini-login" class="input-text required-entry validate-email" />
    													</li>
    													<li><label for="mini-password"><?php //echo $this->__('Password') ?><em><?php //echo $this->__('*') ?></em></label>
    														<input type="password" name="login[password]" id="mini-password" class="input-text required-entry validate-password" />
    													</li>  
    													<li><span class="required"><?php //echo $this->__('* Required Fields') ?></span></li>
													</ul>
													<div class="action-forgot">
														<div class="login_forgotpassword">
															<p><a href="<?php //echo $login->getForgotPasswordUrl() ?>"><?php //echo $this->__('Forgot Your Password?') ?></a></p>
															<p><span><?php //echo $this->__("Don't have an account?") ?></span><a class="create-account-link-wishlist" href="<?php //echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK).'customer/account/create/'; ?>" title="<?php //echo $this->__('Sign Up') ?>"><?php //echo $this->__("Sign Up") ?></a></p>
														</div>
														<div class="actions">
															<button type="submit" class="button"><span><span><?php //echo $this->__('Login') ?></span></span></button>
														</div>                              
													</div>
												</div>
											</form> 
											<script type="text/javascript">
											//<![CDATA[
												var dataTopLoginForm = new VarienForm('top-login-form', true);
											//]]>
											</script>                    
										</div>   
								 -->
<!-- you 隐藏login弹出框 2016-3-16	 -->
									<?php endif; ?>   
								<?php endif;?>
								<?php if(Mage::helper('themeframework/settings')->getGeneral_DisableHoverLogin()!=0 && !Mage::helper('themeframework/settings')->checkPhone()): ?> 
								<script type="text/javascript">
								//<![CDATA[
									(function($) {           
										function effectLoginForm() {
											var sLogin = $('#em-account-login-form');
											var sLink = $('#link-login');
											var sDivLink = $('#em-login-link');  
											if (sLogin.length > 0) {
												//hover login form   
												<?php if(Mage::helper('themeframework/settings')->getGeneral_DisableHoverLogin()==1): ?>                          
													if (isMobile) {
														
														sLink.attr('href', 'javascript:void(0);');
														sLink.click(function(e) {
															sLogin.slideToggle();
														});
													} else {
														var tmlink;
																	 
														function showlink(el) {
															clearTimeout(tmlink);
															tmlink = setTimeout(function() {
																el.slideDown();
															}, 200);
														}    
														function hidelink(el) {
															clearTimeout(tmlink);
															tmlink = setTimeout(function() {
																el.slideUp();
															}, 200);
														}
														sDivLink.mouseover(function(){
															showlink(sLogin);
														});
														sDivLink.mouseout(function(){
															hidelink(sLogin);
														});
													}
												// Popup Login Form
												<?php elseif(Mage::helper('themeframework/settings')->getGeneral_DisableHoverLogin()==2): ?>
													sLink.attr('href', 'javascript:void(0);');
													$("#link-login").click(function(){                            
														 $.fancybox.open('#em-account-login-form',{                              
															minWidth: 300,
															minHeight: 380,                                                                
															openEffect  : 'elastic',
															closeEffect : 'elastic'                        
														});
													});                        
												<?php endif; ?>
											}
										}
										$(document).ready(function(){            
											effectLoginForm();            
										});
									})(jQuery);
								//]]>
								</script> 
								<?php endif;?>
							</div>       
						</div>
					</div>
                </div>             
            </div>
        </div>
    </div>
    
    <div class="em-header-middle">
        <div class="container">
            <div class="row">
                <div class="em-logo col-sm-6"><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo">
                	<strong><?php echo $this->getLogoAlt() ?></strong>
<!-- you	logo更换 2016-04-13  -->                	
                	<h4></h4>
                	<img class="retina-img" src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" />
	 <!-- <h4><?php //echo $this->__('Best goods Fast delivery') ?></h4> --> 
<!-- you	logo更换 2016-04-13  -->
                </a></div>
				<div class="col-sm-18">
					<div class="em-top-cart f-right">
						<?php echo $this->getChildHtml('cart_sidebar'); ?>
					</div>
					<div class="em-search f-right">
						<div class="em-top-search">
							<?php echo $this->getChildHtml('topsearch_nocate_style02') ;?>
						</div>                
					</div>
				</div>
            </div>
        </div>
    </div>
    <?php if(Mage::helper('themeframework/settings')->getGeneral_StickyElement()): ?>
    <div id="em-fixed-top"></div>
    <?php endif;?>
    <div class="em-header-bottom <?php if(Mage::helper('themeframework/settings')->getGeneral_StickyElement()): ?>em-fixed-top<?php endif;?>">
        <div class="container em-menu-fix-pos">
            <div class="row">
				<div class="col-sm-24">
					<div class="em-line">
                        <?php if(Mage::helper('themeframework/settings')->getGeneral_StickyElement()): ?>
    						<div class="em-logo-sticky f-left"><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo">
<!-- you logo更换 2016-3-21 -->
    						<!-- <?php //echo $this->getLogoSrcSmall() ?> -->
    						<img src="<?php echo Mage::getUrl();?>skin/frontend/em0131/em0131_marketdeal/images/logo2.png" alt="<?php echo $this->getLogoAlt() ?>" />
<!-- you logo更换 2016-3-21 -->

    						</a></div>
    					<?php endif;?>                    
						<div class="em-menu-hoz col-sm-22">
							<div id="em-main-megamenu">
								<?php echo $this->getChildHtml('topMenu');?>
							</div>                        
						</div>
                        <?php if(Mage::helper('themeframework/settings')->getGeneral_StickyElement()): ?>
                        <div class="em-search em-search-sticky f-right">
                            <div class="em-top-search"><?php echo $this->getChildHtml('topsearch_fixed') ;?></div>                
                        </div>
                        <div class="em-top-cart f-right em-top-cart-sticky">
                            <?php echo $this->getChildHtml('cart_sidebar'); ?>
                        </div>  
                        <?php endif;?>
					</div>                
                </div>                
            </div>
        </div>
    </div>
</div>
<?php endif;?>


	

<!-- you 全站导航分类目录 2016-04-18 -->				
<?php if ($topListMenu): ?>
	<?php $topListMenus = preg_replace('#\s+#', ' ',trim($topListMenu)); ?>
	<script type="text/javascript">
			//<![CDATA[	
		(function($){

			/*生成菜单列表*/
			var menu_list_html = "<div class='menulset'><?php echo addslashes($topListMenus);?></div>";
			/*追加ul子分类*/
			var top_menu = $(".top_listmenu");
			top_menu.append(menu_list_html);

			/*追加ul子分类标示*/
			$(".topListMenu .level-top >a >span").addClass("fz-arrow");
			/*追加ul子分类高度*/
			var top_menulset_top = $(".menulset .topListMenu").height();
		 	$(".menulset .level-top >ul").css("min-height",top_menulset_top);
			/*追加ul 子分类背景图*/
			var top_list_level = $(".menulset .topListMenu >li");
			if(top_list_level){
				top_list_level.mouseenter(function(){
					var top_list_name = $(this).index();
					var top_list_view = "<?php echo Mage::app()->getStore()->getStoreId() ?>";
					var img_list_name = (top_list_view == "2") ? top_list_name+"_ru.png" : top_list_name+"_en.png";
					var img_list_url  = "url(<?php echo $this->getUrl(''); ?>skin/frontend/em0131/em0131_marketdeal/images/top-navigation/"+img_list_name+") no-repeat";
					$(this).find('ul.level0') .css("background",img_list_url);
				})
			}
			var topgraymenu  = $('.top_listmenu');
			if(topgraymenu)
			{
				topgraymenu.mouseenter(function()
				{
					$('body').append('<div class="appenddiv"></div>');
					$(".appenddiv").height($(document).height()+$(document).scrollTop());
				})
				topgraymenu.mouseleave(function(){
					$('.appenddiv').remove();
				})
			}

		})(jQuery);
			//]]>
	</script>
<?php endif ?>
<!-- you 全站导航分类目录 2016-04-18 --> 

<script type="text/javascript">
	//<![CDATA[
	(function($){
		/*
		*导航栏触发灰度
		*/
		var topgray  = $('#em-main-megamenu .menu-item-depth-0 > ul');
		if(topgray)	{
			topgray.parents('.menu-item-link').mouseenter(function() {
				$('body').append('<div class="appenddiv"></div>');
				$(".appenddiv").height($(document).height()+$(document).scrollTop());
			})
			topgray.parents('.menu-item-link').mouseleave(function(){
				$('.appenddiv').remove();
			})
		}
		/*导航栏触发灰度*/

		/* 
		* you 导航栏添加hot标记 2016-4-12 
		*/
		$(function(){
			var index_span = $(".em-index-span");
			if(index_span) {
				var span = "<h4 class='em_index_aspan'>HOT</h4>";
				index_span.append(span);
			}
		})
		/* you 导航栏添加hot标记 2016-4-12 */

		/*
		* you 热门关键词 2016-06-21
		*/
		<?php $keywordsobjs = preg_replace('#\s+#', ' ',trim($keywordsobj)); ?>
		var keyword = "<?php echo addslashes($keywordsobjs); ?>";
		if(keyword){
			$(".em-wrapper-header .em-top-search .required-entry").focus(function(){
				if ( $("#keywords").length < 1 ) { 
					$(this).after(keyword);
				} 
			})
			$(".em-wrapper-header .em-top-search .required-entry").bind('input propertychange', function() { 
			 	$("#keywords").remove();
			});
		   	$(document).bind("click",function(e){
		   		if($(e.target).closest("#keywords").length == 0 && $(e.target).closest("#search").length == 0 && $(e.target).closest("#search-mobile").length == 0 && $(e.target).closest("#search-fixed-top").length == 0){
			 		$("#keywords").remove();
		   		}
			})		
	   }
		/*you 热门关键词 2016-06-21*/

		/*
		* you 7月活动导航栏链接 2016-07-01
		*/    	
		var nowtime        = "<?php echo $nowtime; ?>"; //当前时间
		var starttimestr   = "<?php echo $starttimestr; ?>"; //活动开始时间
		var endtimestr     = "<?php echo $endtimestr; ?>";//活动结束时间
		var nowtimes       = "<?php echo date('Y-m-d H:m:s',$nowtime);?>";
		$(".landing_nav_home").append("<h4 class='em_index_aspan'>NEW</h4>");
		if(nowtime < endtimestr){//活动时间段
			$(".landing_nav_home").css("display","block");
		}else{
			$(".landing_nav_home").css("display","none");
		}
		/* you 7月活动导航栏链接 2016-07-01 */    

		/*
		* you 首页隐藏全站分类导航 2016-05-05
		*/
		var routeName = "<?php echo $routeName; ?>";
		var homeUrl   = "<?php echo $homeUrl; ?>";
		var route_ru  = "<?php echo $route_ru; ?>";
		var route_cn  = "<?php echo $route_cn; ?>";
		if (routeName == homeUrl || routeName == route_ru || routeName == route_cn) {
			$(".em-header-style31 .em-header-bottom").addClass('index-home');
		}
		/*you 首页隐藏全站分类导航 2016-05-05*/

	})(jQuery);
	var baseUrl = "<?php echo Mage::getBaseUrl()?>";
	//]]>
</script>
<!-- site24x7 counter -->
<?php echo Mage::getModel('core/variable')->loadByCode('counter_site24')->getValue('html');?>
<!-- site24x7 counter -->

<!-- Traffic tracking code -->
<?php echo Mage::getModel('core/variable')->loadByCode('counter_mailru')->getValue('html');?>
<!--// Traffic tracking code -->	

<!-- Yandex.Metrika counter -->
<?php echo Mage::getModel('core/variable')->loadByCode('counter_yandex')->getValue('html');?>	
<!-- //Yandex.Metrika counter -->

<!-- Rating@Mail.ru counter -->
<?php echo Mage::getModel('core/variable')->loadByCode('counter_mailru')->getValue('html');?>	
<!-- //Rating@Mail.ru counter -->

<!-- Facebook Pixel Code -->
<?php echo Mage::getModel('core/variable')->loadByCode('counter_facebook')->getValue('html');?>	
<!-- //Facebook Pixel Code -->

<!-- wang 加载google analytics插件 -->
<script type="text/javascript">
/*Google Analytics*/
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
<?php 
$analyticeKey = Mage::getStoreConfig("google/analytics/account");

if(!empty($customerId)):?>
ga('create', '<?php echo $analyticeKey?>', 'auto',{ 'userId': <?php echo $customerId;?> });
<?php else:?>
ga('create', '<?php echo $analyticeKey?>', 'auto');
<?php endif?>

ga('send', 'pageview');
ga('require', 'ec');
</script>
<!-- wang 加载google analytics插件 -->
<script>
function google_onProductListClick(sku,name,category,position,url,type,id) {
	  ga('ec:addProduct', {
	    'id': sku,
	    'name': name,
	    'category': category,
	    'position': position,
	  });
	  ga('ec:setAction', 'click', {list: type});

	  // Send click with an event, then send user to product page.
	  ga('send', 'event', 'UX', 'click', 'Results', {
	      hitCallback: function() {
	        document.location = url;
	      }
	  });
	}
//Called when a product is added to a shopping cart.
function google_addToCart(sku,name,category,variant,price,id) {
// fbq('track', 'AddToCart', {
//         content_ids: [sku],
//         content_type: 'product',
//         value: price, //OPTIONAL, but highly recommended
//         currency: 'USD' //REQUIRED if you pass a value
// });
//yandex 38564265
yaCounter<?php echo Mage::getModel('core/variable')->loadByCode('counter_yandex')->getValue('text');?>.reachGoal("addtocart");
ga('ec:addProduct', {
'id': sku,
'name': name,
'category': category,
'brand': 'unknow',
'variant': 'unknow',
'price': price,
'quantity': "1"
});
ga('ec:setAction', 'add');
ga('send', 'event', 'UX', 'click', 'add to cart');    // Send data using an event.
dataLayer.push({
    "ecommerce": {
        "add": {
            "products": [
                {
                    "id": id,
                    "name": name,
                    "price": price,
                    "brand":'',
                }
            ]
        }
    }
});
}
</script>
